package com.link.base.base.publicdataimport.controller;

import com.link.base.base.publicdataimport.model.Publicdataimportorg;
import com.link.base.base.publicdataimport.service.PublicdataimportorgService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.BasicServiceException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 黄安邦
 * @date 2018-06-22
 */
@Controller
@RequestMapping("/link/publicdataimportorg")
public class PublicdataimportorgController extends BasicController<Publicdataimportorg> {

    @Resource
    private PublicdataimportorgService publicdataimportorgService;

    @Override
    public BasicService<Publicdataimportorg> getBasicService() throws Exception {
        return publicdataimportorgService;
    }

    /**
     * 删除一条记录
     */
    @Override
    @RequestMapping(value = "/deleteByHeadId")
    @ResponseBody
    public Map<String, Object> deleteById(@JsonParam Publicdataimportorg entity, HttpSession session,
                                          HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<String, Object>();
        try {
            publicdataimportorgService.deleteByHeadId(entity);
            result.put("success", true);
        } catch (BasicServiceException e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
            result.put("detailMessage", e.getDetailMessage());
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
